package eurostar.com.functional;

import java.io.FileInputStream;
import java.util.concurrent.TimeUnit;

import javax.swing.plaf.TableUI;

//import jxl.Sheet;
//import jxl.Workbook;

//import org.openqa.jetty.html.List;
//import org.openqa.jetty.html.Table;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import org.openqa.selenium.support.pagefactory.ElementLocatorFactory;

//import screencompare.Screencompare;
//import screencompare.ScreencompareTestCase;



public class popuphandling  {

	public WebDriver driver = null;
	
	public static void main(String[] args) throws Exception {  
		
		 WebDriver driver = new InternetExplorerDriver();
         driver.get("www.eurostar.com");
         WebElement unitedkingdomlink=driver.findElement(By.linkText("United Kingdom"));
	     unitedkingdomlink.click(); 
	     
	     WebElement from=driver.findElement(By.xpath(".//*[@id='depcity']"));
	     from.sendKeys("");
	     WebElement window1=driver.findElement(By.id("viewall"));
	     driver.switchTo().frame(window1);
	     WebElement text=driver.findElement(By.linkText("Popular")); 
	     text.click();
	     WebElement station=driver.findElement(By.linkText("London"));
	     station.click();
	     driver.switchTo().defaultContent();
	    // String name = driver.getWindowHandle();
	     //System.out.println("the name of the window is " + name.length);
	     //driver.switchTo().Window(24cf4946-fbc7-4b44-82e7-0d2af7a831a3);
	     WebElement to=driver.findElement(By.xpath(".//*[@id='arrcity']"));
	     to.sendKeys("");
	     WebElement window2=driver.findElement(By.id("viewall"));
	     // driver.getWindowHandles();
	     driver.switchTo().frame(window2);
	     WebElement text1=driver.findElement(By.linkText("Popular")); 
	     text1.click();
	     WebElement station1=driver.findElement(By.linkText("Paris"));
	     station1.click();
	     driver.switchTo().defaultContent();
	     WebElement inbounddate=driver.findElement(By.xpath(".//*[@id='eb_journey']/p[3]/span[1]/img"));
	     inbounddate.click();
	    // FileInputStream fi=new FileInputStream("C:\\Users\\Tesco\\Desktop\\Book1.xls");
	     //Workbook wb= Workbook.getWorkbook(fi);
	     //Sheet sh=wb.getSheet(0);
	     //for(int i=0;i<sh.getColumns();i++)
	     //{
	    	 
	   //  }
	    
	     //((JavascriptExecutor) driver).executeScript("var s=document.createElement('script');s.src=http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd");
	   //  WebElement dateframe=driver.findElement(By.xpath(".//*[@id='eb_journey']/p[3]/span[1]/img"));
	     //driver.switchTo().frame(dateframe);
	   // String str[]=
	     WebElement next=driver.findElement(By.className("datepicker_next"));
	    next.click();
	    WebElement ibd=driver.findElement(By.linkText("15"));
	     ibd.click();
	     driver.switchTo().defaultContent();
	     WebElement outbounddate=driver.findElement(By.xpath(".//*[@id='eb_journey']/p[5]/span[1]/img"));
	     outbounddate.click();
	     WebElement next1=driver.findElement(By.className("datepicker_next"));
	     next1.click();
	     WebElement odb=driver.findElement(By.linkText("17"));
	     odb.click();
	     driver.switchTo().defaultContent();
	     //WebElement check=driver.findElement(By.id("oneway"));
	     //check.click();
	     WebElement lf=driver.findElement(By.id("lowfares"));
	    lf.click(); 
	    WebElement search=driver.findElement(By.id("search"));
	     search.click();
	     driver.manage().timeouts().implicitlyWait(7, TimeUnit.SECONDS);
	     WebElement select=driver.findElement(By.xpath(".//*[@id='calendar']/table/tbody/tr[2]/td[4]"));
	     select.click();
	     WebElement continue1=driver.findElement(By.xpath(".//*[@id='select_and_continue']"));
	     continue1.click();
	     //ElementLocatorFactory factory=new AjaxElementLocatorFactory(driver,15);
	     //WebElement select=driver.findElement(By.id("JTime_0.1"));
	    //search.click();
	}
	
}



